#ifndef LOG_H_
#define LOG_H_	

	#define def_LOG_PAGE_LEN 128

	#define def_LOG_RECS_PER_PAGE 4
	#define def_LOG_REC_LEN 32


class LogRecord {
	
	public:
		uint8_t head;
		long lat;
		long lon;
		int gpsTrust;

		int accelX;
		int accelY;
		int accelZ;
		int pitch;
		int roll;
		int yaw;
		int heading;
		int temp;

		unsigned long timeStamp;
		uint8_t tail;

		void init (uint8_t head, long lat, long lon, int gpsTrust, int accelX, int accelY, int accelZ, int pitch, int roll, int yaw, int heading, int temp, unsigned long timeStamp, uint8_t tail);	
};

class LogPage {
	public:
		LogRecord rec[def_LOG_RECS_PER_PAGE];
};

class LogBuff {
	public:
		volatile uint8_t data[def_LOG_PAGE_LEN];
};

class Log {
		int currentRec;
		LogPage workingPage;
	public:
		void init();
		void addGPS(long lat, long lon, int confidence);
		void addIMU(int accelX, int accelY, int accelZ, int pitch, int roll, int yaw, int heading, int temp);
		void printPage(int);
		LogBuff PageToBuff(LogPage);
		LogPage BuffToPage(LogBuff);
};


#endif